export class TableConfig {

  poeTableConfigSelfId?: string
  hospitalId?: string
  compoundId?: string
  orderType?: string
  validState?: string
  operCode?: string
  operName?: string
  operDatetime?: number
  colName?: string
  colType?: string
  colCode?: string
  poeTableConfigId?: string
  settingName?: string | null
  settingCode?: string | null
  poeTableConfigSettingId?: string | null
  settingValue?: string | null
  extend1?: string | null
  extend2?: string | null
  extend3?: string | null
  extend4?: string | null
  extend5?: string | null
  sortno?: number = 0
  orderSysClass?: string[] = []
  poeTableConfigSelfList?: ColumnProperty[] = []
  constructor() {
  }

  /**
   * 获取 cell 宽度
   * @param config
   * @private
   */
  public static getCellWidth(config: TableConfig): number {
    const defaultWitch = config.extend1
    const properties: ColumnProperty[] = config.poeTableConfigSelfList || []
    let configWidth = null
    if (properties && properties.length) {
      const colProperties = properties.find(value => value.settingCode === 'width')
      if (colProperties) {
        configWidth = colProperties.settingValue
      }
    }
    return Number(configWidth || defaultWitch || '150')

  }
}

export class ColumnProperty {
  poeTableConfigSelfId :string | null = null
  hospitalId :string | null = null
  compoundId :string | null = null
  orderType :string | null = null
  validState :string | null = null
  operCode :string | null = null
  operName :string | null = null
  operDatetime :number | null = null
  colName :string | null = null
  colCode :string | null = null
  poeTableConfigId :string | null = null
  settingName :string | null = null
  settingCode :string | null = null
  poeTableConfigSettingId :string | null = null
  settingValue :string | null = null
  settingType :string | null = null
  extend1 :string | null = null
  extend2 :string | null = null
  extend3 :string | null = null
  extend4 :string | null = null
  extend5 :string | null = null
  sortno :number | null = 0
  constructor() {
  }

}
